package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.SpotCatalog;
import cn.wolfcode.wolf2w.repository.SpotCatalogRepository;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.ISpotCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpotCatalogServiceImpl implements ISpotCatalogService {
    @Autowired
    private SpotCatalogRepository spotCatalogRepository;
    @Autowired
    private MongoTemplate template;
    @Override
    public void save(SpotCatalog spotCatalog) {
        spotCatalog.setId(null);
        spotCatalogRepository.save(spotCatalog);
    }

    @Override
    public void update(SpotCatalog spotCatalog) {
        spotCatalogRepository.save(spotCatalog);
    }

    @Override
    public void delete(String id) {
        spotCatalogRepository.deleteById(id);
    }

    @Override
    public SpotCatalog get(String id) {
        return spotCatalogRepository.findById(id).orElse(null);
    }

    @Override
    public List<SpotCatalog> listAll() {
        return spotCatalogRepository.findAll();
    }
    
}
